package com.bulls.demo.hrmsdemo.ib;

import javax.persistence.EntityManager;

import com.bulls.demo.hrmsdemo.dao.LoginDAO;
import com.bulls.demo.hrmsdemo.dao.LoginDAOImpl;
import com.bulls.demo.hrmsdemo.dao.SignupDAO;
import com.bulls.demo.hrmsdemo.dao.SignupDAOImpl;
import com.bulls.demo.hrmsdemo.db.Person;
import com.bulls.demo.hrmsdemo.db.User;

public class SignupLogic {

	static SignupDAO signupDAO;
	public static Person save(Person person, EntityManager entityManager) {
		// TODO Auto-generated method stub
		SignupDAO signupDAO =getDAO();
		User user = new User();
		//user.setUserid(Long.valueOf(person.getUserid()));
		user.setUsername(person.getFullname());
		user.setUsercreated(person.getUserid());
		user.setPassword(person.getPassword());
		signupDAO.save(user, entityManager);
		return getDAO().save(person,entityManager);
	}
	
	public static SignupDAO getDAO(){
		SignupDAOImpl signupDAOImpl = new SignupDAOImpl();
		signupDAO = signupDAOImpl;
		return signupDAO;
	}


}
